package login;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingUtilities;

import nuovoLogin.AccessoDocente;
import nuovoLogin.AccessoStudente;






public class nuovo extends JFrame {
	ActionListener listener;
	private JMenuItem registrati,LoginAdm,LoginStu,LoginDoc,esci;
	private String titolo="LOGIN";
	//costruttore
	public nuovo(){
		setTitle(titolo);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JMenuBar menu=new JMenuBar();
		
		this.setJMenuBar(menu);
		JMenu fileMenu=new JMenu ("LOGIN");
		
		menu.add(fileMenu);
		//creo le opzioni da inserire una volta aver cliccato sul tasto login
		JMenu opzione1=new JMenu("Accedi come");
		fileMenu.add(opzione1); 
		LoginAdm=new JMenuItem(" Amministratore");
		LoginAdm.addActionListener(listener);
		opzione1.add(LoginAdm);
		LoginDoc=new JMenuItem(" Docente");
		LoginDoc.addActionListener(listener);
		opzione1.add(LoginDoc);
		LoginStu=new JMenuItem(" Studente");
		LoginStu.addActionListener(listener);
		opzione1.add(LoginStu);
		fileMenu.addSeparator();
		registrati=new JMenuItem("Registrati");
		registrati.addActionListener(listener);
		fileMenu.add(registrati);
		esci=new JMenuItem("Esci");
		esci.addActionListener(listener);
		fileMenu.add(esci);
		JMenu Help=new JMenu("HELP");
		menu.add(Help);
		
		 setLocation(400, 300);
		 setSize(450,270);
	
	LoginAdm.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			 if(MioLogin.getInstance()==null){
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					Amministratore inst = new Amministratore();
					inst.setLocationRelativeTo(null);
					
					
				}
				
				
			});
		}}
	});

	LoginDoc.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			 if(MioLogin.getInstance()==null){
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					AccessoDocente inst = new AccessoDocente();
					inst.setLocationRelativeTo(null);
				
					
					
				}
				
				
			});
		}}
	});

	LoginStu.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			 if(MioLogin.getInstance()==null){
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					AccessoStudente inst = new AccessoStudente();
					inst.setLocationRelativeTo(null);
					
					
				}
				
				
			});
		}}
	});
	}
 public static void main(String[]args){
	   
		 nuovo j=new nuovo();
		 j.setTitle("LOGIN");
		 j.setSize(450,270);
		 j.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		 j.setVisible(true);
		 j.setLocation(400, 300);
		
		
	 }

}
